function count_same_elements(collection) {
  let object={};
  let arr=[],arr1=[];
  for(let item of collection){
    if(item.length===1){
      if(!object[item]){
      object[item]={};
      object[item].key=item;
      object[item].count=1;
    }
    else{
      object[item].count++;
    }
   }
   else {
    arr1=item.split('');
    object[item]={};
    object[item].key=arr1[0];
    object[item].count=parseInt(arr1[2]);
  }
}
    for(let i in object){
      arr.push(object[i]);
    }
    return arr;
}

module.exports = count_same_elements;
